package com.tarena.lbs.coupon.enums;

import lombok.Getter;

/**
 * @author: feng
 * @date: 2025/10/10 14:07
 * @Version: 1.0
 * @description: 用户的优惠券状态
 */
@Getter
public enum UserCouponStatus {
    UNUSED(0, "未使用"),
    USED(1, "已使用"),
    EXPIRED(2, "已过期");
    
    private final Integer code;
    private final String message;

    UserCouponStatus(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * 根据code获取用户优惠券状态
     *
     * @param code 状态码
     * @return 用户优惠券状态枚举
     */
    public static UserCouponStatus fromCode(Integer code) {
        for (UserCouponStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown user coupon status code: " + code);
    }
}